package ochart.renders
{
	import ochart.renders.bitmap.BitmapRendererFactory;
	import ochart.renders.vector.VectorRendererFactory;

	public class RendererFactory implements IRendererFactory
	{
		private static var _instance:RendererFactory = null;
		
		public static function get instance():RendererFactory
		{
			if(!_instance)
			{
				_instance = new RendererFactory();
			}
			return _instance;
		}
		
		private var _type:String = null;
		
		public function get type():String
		{
			return _type;
		}
		
		public function set type(value:String):void
		{
			_type = value;
			
			switch(_type)
			{
				case RendererType.BITMAP:
					this.factory = new BitmapRendererFactory;
					break;
				case RendererType.VECTOR:
					this.factory = new VectorRendererFactory();
					break;
				default:
					this.factory = null;
			}
		}
		
		public var factory:IRendererFactory = null;
		
		public function RendererFactory()
		{
			
		}
		
		public function create(alias:String):Renderer
		{
			if(this.factory)
			{
				return this.factory.create(alias);
			}
			return null;
		}
	}
}